<!--
 * @Description  : 
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2021-12-24 16:58:02
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-05-06 14:37:36
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\order-management\\components\\bulk-detail-change\\bulk-detail-change.component.html
 * Copyright (C) 2022 huzhenhong. All rights reserved.
-->

<page-header-wrapper [title]="''" [logo]="logo" [content]="headerContent">
  <ng-template #logo>
    <button nz-button nz-tooltip nzTooltipTitle="返回上一页" (click)="goBack()">
      <i nz-icon nzType="left" nzTheme="outline"></i>
    </button>
  </ng-template>

  <ng-template #headerContent>
    <div nz-row>
      <button nz-button nzType="primary" nzSize="small" nzDanger>{{i?.billStatusLabel}}</button>
      <h4 class="ml-md" style="font-size: 18px;">订单号: {{ i?.billCode }}</h4>
    </div>
    <div nz-row style="display: flex; justify-content: end;" class="mb-xs">
      <div nz-col>
        <button nz-button (click)="cancelChange()">取消修改</button>
        <button nz-button nzType="primary" (click)="save()" nzGhost>保存修改</button>
      </div>
    </div>
    <div>
      <div sv-container>
        <sv label="网络货运人">{{ i?.goodsResource?.enterpriseInfoName }} </sv>
        <sv label="货主">{{ i?.goodsResource?.shipperAppUserName }} </sv>
        <sv label="所属项目">{{i?.goodsResource?.enterpriseProjectName}}</sv>
        <sv label="服务类型">{{i?.goodsResource?.serviceTypeLabel}}</sv>
        <sv label="录单员">{{i?.createUserName}} {{ i?.createUserPhone ? "/" + i?.createUserPhone : ''}} </sv>
        <sv label="调度员">{{i?.goodsResource?.dispatchName}}{{ i?.goodsResource?.dispatchPhone ? "/" +
          i?.goodsResource?.dispatchPhone : ''}} </sv>
      </div>
      <nz-tabset style="margin-top: 15px;">
        <nz-tab nzTitle="装卸货信息" (nzClick)="goDistance(distannce1)">
        </nz-tab>
        <nz-tab nzTitle="基本信息" (nzClick)="goDistance(distannce2)">
        </nz-tab>
        <nz-tab nzTitle="运费信息" (nzClick)="goDistance(distannce3)">
        </nz-tab>
        <nz-tab nzTitle="附件信息" (nzClick)="goDistance(distannce4)">
        </nz-tab>
        <nz-tab nzTitle="轨迹信息" (nzClick)="goDistance(distannce5)">
        </nz-tab>
      </nz-tabset>
    </div>
  </ng-template>
</page-header-wrapper>
<nz-card nzTitle="运单进度" #distannce1>
  <div class="approval-status">
    <div style="width: 60%; margin: 0 auto">
        <nz-steps [nzCurrent]="i?.scheduleVOList?.length + 1" nzLabelPlacement="vertical">
          <nz-step           *ngFor="let item of i?.scheduleVOList"     [nzTitle]="item.state"    
          [nzSubtitle]="item.stateTime"     [nzStatus]="item.displayStatus === 'SHOW' ? 'finish' : 'wait'"  >
            </nz-step>
         </nz-steps>
    </div>
  </div>
</nz-card>


<nz-card>
  <div class="card-title">装卸货信息<span class="tip-font">预计公里数：{{ totalDistance }}km，预计行程耗时：{{ totalTime }}小时</span></div>

  <form nz-form [formGroup]="validateForm1" role="form">
    <div nz-row [nzGutter]="24">
      <div nz-col [nzSpan]="10">
        <div *ngFor="let data1 of startInfo; let idx = index">
          <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>装货地</nz-form-label>
            <nz-form-control [nzErrorTip]="'请输入装货地'">
              <div class="align-center">
                <nz-input-group [nzSuffix]="endInconTemp1">
                  <input nz-input [(ngModel)]="data1.detailedAddress"
                    (click)="openMap('start', idx,data1.detailedAddress)" formControlName="loadAddress{{ idx }}"
                    placeholder="请输入装货地" readonly="true" />
                </nz-input-group>
              </div>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>联系人</nz-form-label>
            <div style="display: flex;">
              <nz-form-control [nzErrorTip]="'请输入联系人姓名'">
                <input nz-input [(ngModel)]="data1.appUserName" formControlName="loadName{{ idx }}"
                  name="loadName{{ idx }}" maxlength="30" placeholder="请输入联系人姓名" />
              </nz-form-control>
              <nz-form-control [nzErrorTip]="'请输入联系人电话'">
                <input style="margin-left: 12px" nz-input [(ngModel)]="data1.contractTelephone" maxlength="11"
                  formControlName="loadPhone{{ idx }}" name="loadPhone{{ idx }}" placeholder="请输入联系人电话" />
              </nz-form-control>
            </div>
          </nz-form-item>
        </div>
      </div>
      <div nz-col [nzSpan]="4">
        <div style="display: flex; justify-content: center">
          <span class="swap-icon" (click)="swapAddress()"><i nz-icon nzType="swap" nzTheme="outline"></i></span>
        </div>
      </div>
      <div nz-col [nzSpan]="10">
        <div *ngFor="let data2 of endInfo; let idx = index">
          <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>卸货地</nz-form-label>
            <nz-form-control [nzErrorTip]="'请输入卸货地'">
              <div class="align-center">
                <nz-input-group [nzSuffix]="endInconTemp1">
                  <input nz-input [(ngModel)]="data2.detailedAddress"
                    (click)="openMap('end', idx,data2.detailedAddress)" formControlName="unloadAddress{{ idx }}"
                    placeholder="请输入卸货地" name="unloadAddress{{ idx }}" readonly="true" />
                </nz-input-group>
              </div>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>联系人</nz-form-label>
            <div style="display: flex;">
              <nz-form-control [nzErrorTip]="'请输入联系人姓名'">
                <input nz-input [(ngModel)]="data2.appUserName" maxlength="30" formControlName="unloadName{{ idx }}"
                  name="unloadAddress{{ idx }}" placeholder="请输入联系人姓名" />
              </nz-form-control>
              <nz-form-control [nzErrorTip]="'请输入联系人电话'">
                <input style="margin-left: 12px" nz-input [(ngModel)]="data2.contractTelephone"
                  formControlName="unloadPhone{{ idx }}" name="unloadAddress{{ idx }}" maxlength="11"
                  placeholder="请输入联系人电话" />
              </nz-form-control>
            </div>
          </nz-form-item>
        </div>
      </div>
    </div>
    <!-- <div nz-row [nzGutter]="24" style="margin-top: 24px">
      <div nz-col [nzSpan]="10">
        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired>装货时间</nz-form-label>
          <nz-form-control [nzErrorTip]="'请输入装货时间'">
            <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="loadingTime" name="loadingTime"></nz-date-picker>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="4"></div>
      <div nz-col [nzSpan]="10">
        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired>卸货时间</nz-form-label>
          <nz-form-control [nzErrorTip]="'请输入卸货时间'">
            <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="unloadingTime" name="unloadingTime"></nz-date-picker>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div> -->
    <ng-template #endInconTemp1><i nz-icon nzType="environment" nzTheme="outline"></i></ng-template>
  </form>
</nz-card>
<nz-card nzTitle="基本信息" #distannce2>
  <sf #sf3 [schema]="schema3" [formData]="sf3data" [button]="'none'" [ui]="ui3"></sf>
  <sf #sf4 [schema]="schema4" [formData]="sf4data" [button]="'none'" [ui]="ui4">
    <ng-template sf-template="weight" let-item let-ui="ui">
      {{i?.goodsInfoList?.[0]?.weight}}吨,{{i?.goodsInfoList?.[0]?.volume}}方,{{i?.goodsInfoList?.[0]?.number}}件
    </ng-template>
    <ng-template sf-template="volume" let-item let-ui="ui">
      <nz-input-group [nzAddOnAfter]="'方'">
        <input nz-input type="number" [ngModel]="item.value" min="0" [max]="999999" step="0.01"
          (ngModelChange)="item.setValue($event)" placeholder="总体积" />
      </nz-input-group>
    </ng-template>

    <ng-template sf-template="number" let-item let-ui="ui">
      <nz-input-group [nzAddOnAfter]="'车'">
        <input nz-input type="number" [ngModel]="item.value" min="0" [max]="999999" step="0.01"
          (ngModelChange)="item.setValue($event)" placeholder="总车次" />
      </nz-input-group>
    </ng-template>

    <ng-template sf-template="carmand" let-item let-ui="ui">
      {{ i?.carModel }}{{ i?.carLength ? "/" + i?.carLength : ''}}
    </ng-template>
    <ng-template sf-template="drivers" let-item let-ui="ui">
      {{i?.driverName}}{{ i?.driverPhone ? "/" + i?.driverPhone : ''}}{{ i?.carNo ? "/" + i?.carNo : ''}}
    </ng-template>
    <ng-template sf-template="weightModel" let-item let-ui="ui">
      {{ i?.driverCarModelLabel }},{{ i?.driverCarLengthLabel }}米,{{ i?.driverCarWeight }}吨
    </ng-template>

    <ng-template sf-template="loadTime" let-item let-ui="ui">
      <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" [(ngModel)]="loadTime"></nz-date-picker>
    </ng-template>
    <ng-template sf-template="unloadTime" let-item let-ui="ui">
      <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" [(ngModel)]="unloadTime"></nz-date-picker>
    </ng-template>

  </sf>
</nz-card>
<!--
结算依据为1时，卸货时间不为空，显示运费信息，否则隐藏
结算依据为2时，装货时间不为空，显示运费信息，否则隐藏
 -->
<nz-card [nzTitle]="priceTitel" #distannce3
  [hidden]="!(i?.settlementBasis ==='1' && i?.unloadTime) && !(i?.settlementBasis ==='2' && i?.loadTime)">
  <ng-template #priceTitel>
    <span>运费信息</span><span
      style="padding-left: 24px; color: #f59a23;font-size: small;">到货后{{i?.goodsResource?.paymentDays}}天内支付运费</span>
  </ng-template>
  <div style="margin-bottom: 18px">
    <span style="color: #da001b; font-size: 18px"> {{ i?.freightPrice }}{{ i?.freightTypeLabel }} </span>（{{
    i?.settlementBasisLabel }}，{{
    i?.ruleLabel
    }}）
  </div>
  <st #st [data]="billExpenses" [columns]="logColumns" [ps]="0" [page]="{ show: false, showSize: false }">
    <ng-template st-row="prices" let-item let-index="index">
      {{ item.price + item.surcharge | currency }}
    </ng-template>
    <ng-template st-row="PriceType" let-item let-index="index"> 到付 </ng-template>
    <ng-template st-row="price" let-item let-index="index"> {{item.price | currency}} </ng-template>
    <ng-template st-row="surcharge" let-item let-index="index"> {{item.surcharge | currency}} </ng-template>
  </st>
  <div>
    总计：<span style="color: #da001b; font-size: 18px">{{ i?.totalAmount | currency }}</span> （运费{{ i?.totalFreight |
    currency }}，
    附加费{{ i?.totalSurcharge | currency }}，附加费率{{ i?.totalRate * 100 | number: '0.2-2' }}%）
  </div>
  <div *ngIf=" i?.payeeId !== i?.driverId" class="mt-xs">车队长：{{ i?.payeeName }}/{{ i?.payeePhone }}/{{ i?.payeeIdNo }}
  </div>
</nz-card>

<nz-card nzTitle="附件信息" #distannce4>
  <sv-container>
    <sv label="协议附件">
      <a *ngIf="i?.contractContent?.contractContent" (click)="agreement('1')">查看附件</a> &nbsp;&nbsp;&nbsp;&nbsp;
      <a *ngIf="i?.supplementContent?.contractContent" (click)="agreement('2')">补充协议</a>
    </sv>
  </sv-container>
  <sv-container col="2" class="mt-md">
    <sf #sf mode="edit" [schema]="schema" [ui]="ui" [formData]="formData" button="none"></sf>
  </sv-container>
</nz-card>
<nz-card nzTitle="补充信息">
  <sv-container>
    <sv label="是否回单">
      {{ i?.supplementaryInformationVO?.stateReceipt ? '是' : '否' }}
    </sv>
    <sv label="回单类型" *ngIf="i?.supplementaryInformationVO?.stateReceipt">
      {{ i?.supplementaryInformationVO?.receiptType === '1' ? '电子回单' : '纸质回单' }}
    </sv>
    <sv label="联系人" *ngIf="i?.supplementaryInformationVO?.stateReceipt"> {{
      i?.supplementaryInformationVO?.receiptUserName }} / {{ i?.supplementaryInformationVO?.phon }} </sv>
    <sv label="所在地区" *ngIf="i?.supplementaryInformationVO?.stateReceipt">
      {{ i?.supplementaryInformationVO?.area }}
    </sv>
    <sv label="详细地址" *ngIf="i?.supplementaryInformationVO?.stateReceipt">
      {{ i?.supplementaryInformationVO?.address }}
    </sv>

  </sv-container>
  <sv-container col="1" class="mt-md">
    <sv label="回单凭证" *ngIf="i?.supplementaryInformationVO?.stateReceipt">
      <nz-upload class="avatar-uploader" [nzAction]="service.$api_upload_url" [nzName]="'multipartFile'"
        nzListType="picture-card" [(nzFileList)]="listImagUrls" [nzShowButton]="listImagUrls.length < 5"
        [nzPreview]="handlePreview1" [nzBeforeUpload]="beforeUpload" (nzChange)="handleChange1($event)">
        <div>
          <i nz-icon nzType="plus"></i>
          <div style="margin-top: 8px">请上传图片</div>
        </div>
      </nz-upload>
      <!-- <nz-modal [nzVisible]="previewVisible1" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible1 = false">
      <ng-template #modalContent>
        <img [src]="previewImage1" [ngStyle]="{ width: '100%' }" />
      </ng-template>
    </nz-modal> -->
    </sv>
    <sv label="备注">
      {{i?.goodsResource?.remarks}}
    </sv>
  </sv-container>
</nz-card>



<nz-card #distannce5>
  <div nz-row>
    <p class="detail_title"><span>|</span> 轨迹信息</p>
    <button style="margin-left: 15px;" nz-button nzSize="small" nzType="primary" (click)="restMap()" [disabled]="">刷新</button>
  </div>
  <div nz-row>
    <div nz-col [nzSpan]="24">
      <amap-path-simplifier [mapWidth]="'100%'" [mapHeight]="'300px'" [mapList]="mapList">
      </amap-path-simplifier>
      <st [scroll]="{ y: '350px' }" #st [data]="addressItems"  [noResult]='fuck'  [columns]="logColumns2" [ps]="0"
        [page]="{ show: false, showSize: false }" size="small" class="map_st">
        <ng-template #fuck>
          <div>
            <img class="mr-sm" [src]="'../../../../../assets/none.svg'" width="40" height="40" />
          </div>
          暂无停车信息
        </ng-template>
      </st>
      <nz-radio-group [(ngModel)]="trajectory" (ngModelChange)="trajectoryChange($event)" class="map_radio">
        <label nz-radio-button nzValue="car">车辆轨迹</label>
        <label nz-radio-button nzValue="driver">司机轨迹</label>
      </nz-radio-group>
    </div>
  </div>
</nz-card>

<nz-modal [(nzVisible)]="isVisible" [nzFooter]="nzModalFooter" [nzTitle]="modalTitle" (nzOnOk)="handleOK()"
  nzWidth="1000px" (nzOnCancel)="handleCancel()">
  <ng-container *nzModalContent>
    <div *ngIf="!modalcontent">暂无附件信息</div>
    <div [innerHTML]="modalcontent"></div>
  </ng-container>
  <ng-template #nzModalFooter>
    <button nz-button nzType="primary" (click)="handleOK()" [disabled]="">取消</button>
    <button nz-button nzType="default" (click)="handleCancel()">确定 </button>
  </ng-template>
</nz-modal>